#ifndef _MINI_GAME_H_
# define _MINI_GAME_H_

# include <SDL/SDL.h>
# include <SDL/SDL_ttf.h>
# include "Image.h"
# define BULLETS	42

class MiniGame
{
public:
	static int const LEFT;
	static int const RIGHT;
	static int const UP;
	static int const BOTTOM;
	bool m_mitraillette;

private:
	struct piece
	{
		static int const FORBIDDEN_LEFT;
		static int const FORBIDDEN_RIGHT;
		static int const FORBIDDEN_UP;
		static int const FORBIDDEN_BOTTOM;
		static int const MAX_LIFE;

		SDL_Rect Position;
		int Life;
		int directionX;
		int directionY;

		piece();
	};

	struct explosion
	{
		Image Explosion;
		SDL_Rect Positions[25];

		explosion();
	};

	struct bullet
	{
		Image Bullet;
		SDL_Rect Positions[3];

		bullet();
	};

	struct bullets
	{
		SDL_Surface* Ptr[BULLETS];
		SDL_Rect	 Positions[BULLETS];
		int			 Lifes[BULLETS];

		bullets();
	};

	SDL_Surface* m_screen;
	Image m_piece;
	Image m_cursor;
	int m_level;
	int m_nbPieces;
	int m_nbDead;
	int m_speed;
	piece* m_pieces;
	explosion m_explosion;
	bullet m_bullet;
	bullets m_bullets;
	bool m_showScore;
	unsigned int m_score;
	unsigned int m_lastScore;
	Image m_scoreText;
	TTF_Font* m_digital;

public:
	MiniGame(SDL_Surface* _screen);
	~MiniGame();

	void initLevel(int _level);
	void draw();
	void doEvents();

private:
	void drawPieces();
	void drawCursor();
	void movePieces(int i);
	void piecesEvent(int& nbDead);
	void checkMitraillette(bool& _clicked);
	void clickEvent(int x, int y);

private:
	MiniGame(MiniGame const&);
	MiniGame& operator=(MiniGame const&);
};

#endif // _MINI_GAME_H_
